/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.service.model;

import org.tnmk.worktime.utils.NumUtils;

/**
 *
 * @author Administrator
 */
public class Time {

  private int hours;
  private int minutes;
  private int seconds;
  
  public Time(float hoursDecimal){
    hours = (int) hoursDecimal;
    float minutesDecimal = ((hoursDecimal - hours) * 60);
    minutes = (int) minutesDecimal;
    seconds = (int) ((minutesDecimal - minutes) * 60);
  }
  public Time(int hours, int minutes, int seconds) {
    this.hours = hours;
    this.minutes = minutes;
    this.seconds = seconds;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(NumUtils.toString(this.hours, 3)).append(":").append(NumUtils.toString(this.minutes, 2)).append(":").append(NumUtils.toString(this.seconds, 2));
    return sb.toString();
  }

  /**
   * @return the hours
   */
  public int getHours() {
    return hours;
  }

  /**
   * @param hours the hours to set
   */
  public void setHours(int hours) {
    this.hours = hours;
  }

  /**
   * @return the minutes
   */
  public int getMinutes() {
    return minutes;
  }

  /**
   * @param minutes the minutes to set
   */
  public void setMinutes(int minutes) {
    this.minutes = minutes;
  }

  /**
   * @return the seconds
   */
  public int getSeconds() {
    return seconds;
  }

  /**
   * @param seconds the seconds to set
   */
  public void setSeconds(int seconds) {
    this.seconds = seconds;
  }

}
